package gdut.edu.demo02;

/**
 * @Description 单链表测试
 * @Author JiaFu
 * @Date 2022/7/6 17:11
 */
public class TestMyNode {
    public static void main(String[] args) {
        MyNode myNode = new MyNode(1);
        MyNode myNode2 = new MyNode(2);
        MyNode myNode3 = new MyNode(3);
        myNode.append(myNode2);
        myNode.append(myNode3);
        System.out.println("myNode.getData() = " + myNode.getData());
        System.out.println("myNode.next().getData() = " + myNode.next().getData());
        System.out.println("myNode.next().next().getData() = " + myNode.next().next().getData());
        myNode.append(new MyNode(4));
        System.out.println("myNode.next().next().next().getData() = " + myNode.next().next().next().getData());
        System.out.println("myNode.isLast() = " + myNode.isLast());
        System.out.println("myNode.next().next().next().isLast() = " + myNode.next().next().next().isLast());
//        打印所有节点信息
        myNode.show();
//        删除当前节点的下一个节点
        myNode.next().removeNext();
        myNode.show();
//        插入节点到当节点的下一个节点
        myNode.insert(new MyNode(7));
        myNode.show();
    }
}
